﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web.UI.WebControls;
using FS.Business;
using FS.Common.DotNetCode;
using FS.Common.DotNetUI;
using FS.Web.UserControl;
using FS.Common.DotNetData;
using FS.Common.DotNetBean;
using FS.Common.DotNetEncrypt;
using FS.DataBase;
using System.Collections;
using System.Linq;
using System.Data.SqlClient;
using System.Data.Common;
using System.Web.SessionState;
using System.Web;

namespace FS.Web.BLL.Visa_Base
{
    public partial class shi_visa_Info6 : System.Web.UI.Page
    {
        visa_dao _visa = new visa_dao();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.PageControl1.pageHandler += new EventHandler(this.pager_PageChanged);
            if (!base.IsPostBack)
            {
                initBase_City();
                initBase_CertType();
            }
        }

        protected void pager_PageChanged(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
        //protected void ddlp_city_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    string ls_city = this.ddlp_city.SelectedValue;
        //    DataTable dt = _visa.GetSelect_CertTypeInfoByCityID(ls_city);
        //    ControlBindHelper.BindDropDownList(dt, this.Ref_CertType, "name", "id", "请选择");
        //}
        //所属国家
        private void initBase_City()
        {
            DataTable dt = _visa.GetSelect_CityInfo();
            ControlBindHelper.BindDropDownList(dt, this.ddlp_city, "city_name", "city_id", "请选择");
        }
        protected void lbtSearch_Click(object sender, EventArgs e)
        {
            this.Hchange.Value = "1";
            DataBindGrid();
        }

        //签证类型
        private void initBase_CertType()
        {
            DataTable dt = _visa.GetSelect_CertType();
            ControlBindHelper.BindHtmlSelect(dt, this.Ref_CertType, "property_value", "property_id", "请选择");
        }
        private void DataBindGrid()
        {
            string sql = "";
            int count = 0;
            if (this.Hchange.Value == "1")
            {
                this.PageControl1.PageIndex = 1;
                this.Hchange.Value = "0";
            }
            if (this.Supply_Name.Value != "")
            {
                sql = sql + " and Base_supply.Supply_Name like '%" + this.Supply_Name.Value + "%'";

            }
            if (this.ddlp_city.Text != "")
            {
                sql = sql + " and Visa_InfoDetail.City_id='" + this.ddlp_city.Text + "'";

            }
            if (this.InfoDetail_Submitdate.Value != "")
            {
                sql = sql + " and visa_Infodetail.[InfoDetail_Submitdate]='" + this.InfoDetail_Submitdate.Value + "'";
            }
            //CertType.parm_Value
            if (this.Ref_CertType.Value != "")
            {
                sql = sql + " and CertType.parm_Value='" + this.Ref_CertType.Value + "'";
            }
            StringBuilder sqls = new StringBuilder();
            IList<SqlParam> IList_param = new List<SqlParam>();
            sqls.Append(sql);
            DataTable dt = _visa.shi_GetVisaInfo6Page(sqls, IList_param, this.PageControl1.PageIndex, this.PageControl1.PageSize, ref count);
            ControlBindHelper.BindRepeaterList(dt, this.rp_Item);
            this.PageControl1.SetPageCount(count);  
        }

        protected void lbtExport_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel.numberformat:@";
            this.EnableViewState = false;
            Response.Charset = "UTF-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls");
            Response.Write(printHid.Value);
            Response.End();
        }
    }
}